<template>
	<view class="page">
		<!-- 带背景的透明导航栏 -->
		<NavbarRoundImg title="我的" backgroundColor="rgba(0,0,0,0)" titleColor="#000" height="676rpx"></NavbarRoundImg>
		<!-- 用户 -->
		<UserInfo :data="userInfo" :isLogin="isLogin"></UserInfo>
		<view class="u-margin-20">
			<u-card :border="false" :show-head="false" margin="0" padding="30">
				<view slot="body">
					<view class="u-flex menu-data"
						@click="link_to_page('/pages-mine/pages/userbm?id=' + userInfo.OtherId + '&type=' + userInfo.UserType)"
						v-if="userInfo.UserType == 1 || userInfo.UserType == 2">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-personage.png'">
						</image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 个人信息 </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/user')"
						v-if="userInfo.UserType == 0 || userInfo.UserType == 3||userInfo.UserType == null">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-personage.png'">
						</image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 个人信息 </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/agreement')">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-agreement.png'">
						</image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 服务协议 </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/aboutus')">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-personage.png'">
						</image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 关于我们 </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/releaseList')">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-issue.png'"></image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 发布招聘 </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/insurance')">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/baoxianshouhou.png'"></image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 保险售后 </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/legalaffairs')">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-work-tianp.png'"></image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 法务咨询 </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data">
						<button open-type="contact" bindcontact="handleContact" session-from="sessionFrom"
							class="int_btn">
							<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-phone.png'">
							</image>
							<view class="u-flex-1 u-padding-left-18 int_test">联系管家</view>
							<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
						</button>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/settingNanny')"
						v-if="userInfo.UserType == 1">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-nanny.png'"></image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 家政入口(保姆) </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/settingCleaning')"
						v-if="userInfo.UserType == 2">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-nanny.png'"></image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 家政入口(保洁) </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
					<view class="u-flex menu-data" @click="link_to_page('/pages-mine/pages/settingManager')"
						v-if="userInfo.UserType == 3">
						<image style="width: 42rpx;height: 42rpx;" :src="'/static/image/icon-mine-nanny.png'"></image>
						<view class="u-flex-1 u-padding-left-18 int_test"> 家政入口(家政公司) </view>
						<image style="width: 13rpx;height: 24rpx;" src="/static/image/icon-right.png"></image>
					</view>
				</view>
			</u-card>
		</view>
	</view>
</template>

<script>
	import NavbarRoundImg from '@/components/navbar/navbar-round-img.vue';
	import UserInfo from '@/pages/mine/components/user-info.vue';

	export default {
		components: {
			NavbarRoundImg,
			UserInfo
		},
		data() {
			return {
				isLogin: false,
				// 用户信息
				userInfo: {},
				menuList: [{
						name: '个人信息',
						path: '/pages-mine/pages/user',
						icon: 'icon-mine-personage'
					},
					{
						name: '服务协议',
						path: '/pages-mine/pages/agreement',
						icon: 'icon-mine-agreement'
					},
					{
						name: '关于我们',
						path: '/pages-mine/pages/aboutus',
						icon: 'icon-mine-personage'
					},
					{
						name: '家政入口',
						path: '/pages-mine/pages/setting',
						icon: 'icon-mine-nanny'
					},
					{
						name: '发布招聘',
						path: '/pages-mine/pages/release',
						icon: 'icon-mine-issue'
					}
				]
			};
		},
		onShow() {
			let $this = this;
			this.getWxCode(code => {
				this.$u.api.getOpenId(code).then(res => {
					if (res && res.code == 0) {
						this.userInfo = res.data || {};
						uni.setStorageSync('USER_INFO', this.userInfo);
						if (res.isOk == true) {
							uni.setStorageSync('IS_LOGIN', true);
						} else {
							uni.setStorageSync('IS_LOGIN', false);
						}
						$this.isLogin = uni.getStorageSync('IS_LOGIN');
					} else {
						uni.setStorageSync('IS_LOGIN', false);
					}
				});
			});
		},
		methods: {
			// 基于uni的获取code方法
			getWxCode(callBack) {
				uni.login({
					provider: 'weixin',
					onlyAuthorize: true,
					success: loginRes => {
						callBack(loginRes.code);
					}
				});
			},
			handleContact(e) {
				console.log(e.detail.path)
				console.log(e.detail.query)
			}
		}
	};
</script>

<style lang="scss" scoped>
	.page {
		.int_test {
			height: 24px;
			line-height: 24px;
			font-size: 16px;
			text-align: left;
			color: #101010;
		}

		.int_btn {
			width: 100%;
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
			align-items: center;
			border: none;
			background-color: transparent;
			padding: 0;
		}

		.int_btn::after {
			border: none;
		}

		.int_btn::after {
			background-color: transparent;
		}
	}

	.menu-data {
		padding: 32rpx 0 32rpx;
		border-bottom: 2rpx solid #dcdcdc;

		&:first-child {
			padding-top: 10rpx;
		}

		&:last-child {
			border: none;
			padding-bottom: 10rpx;
		}
	}
</style>